CC = gcc
FLAGS = -std=c11 -Wall -Werror -Wextra
SOURCE = s21_matrix.c
OBJECT = $(patsubst %.c,%.o, $(SOURCE))
TEST = matrix_test.c

all: s21_matrix.a

s21_matrix.a:
	$(CC) -c $(FLAGS) $(SOURCE)
	ar -rcs -o s21_matrix.a $(OBJECT)
	rm -rf *.o

test:
	$(CC) $(FLAGS) -o s21_matrix.test --coverage $(SOURCE) $(TEST) -lcheck -lm -lsubunit
	./s21_matrix.test

clean:
	rm -rf *.a *.gcno *.gcda coverage_html *.o *.test *.info

gcov_report: clean test
	lcov -d . -c -o s21_matrix.test.info
	genhtml -o coverage_html s21_matrix.test.info

clang:
	clang-format --style=google -n *.c
	clang-format --style=google -n *.h

full_test: clean gcov_report clang
	valgrind --tool=memcheck -q --leak-check=yes ./s21_matrix.test